jQuery(function(){
	
	//signature tab
	var _signTab = "signTab";
	
	var _signatureCreateModal = $("#signatureCreateModal");
	var _signatureModal = "signatureModal";
	var _signatureModalClose = "signatureModalClose";
	var _signatureContent = "signatureContent";
	var _getSignatureList = "getSignatureList";
	var _signatureList = "signatureList";
		
	var viewFileType = "type";
	var defaultColor = "#000000"
		
	var signatureDeleteClass = "fwr-signature-item-delete";
		
	
	
	//type
	var _signatureStyle = "signatureStyle";
	var _signatureFontColor = "signatureFontColor";
	var _signatureColorLi = "signatureColorLi";
	var _signatureInput = "signatureInput";
	var _signatureClearAll = "clearAll";
	var _signatureInputBackgroud = "signatureInputBackgroud";
	var _fontFamilyType = "fontFamilyType";
	
	var color = defaultColor
	var fontType = "B";
	var fontFamily = "Anacondas";
	var fontB = false;
	var fontI = false;
	var fontU = false;
	var fontSize = 56;
	
	
	//draw
	var drawColor = defaultColor;
	var _signatureColorLiDraw = "signatureColorLiDraw"
	var _canvasDiv = "canvasDiv";
	var _signatureColorDraw = "signatureColorDraw";
	var _clearAllDraw = "clearAllDraw";
	var _drawBackground = "drawBackground";

	var canvasDiv = document.getElementById('canvasDiv');  
	var canvas = document.createElement('canvas');
	var canvasWidth = "490";
	var canvasHeight = "150";
	canvas.setAttribute('width', canvasWidth);  
	canvas.setAttribute('height', canvasHeight);  
	canvas.setAttribute('id', 'canvas');  
	canvasDiv.appendChild(canvas);  
	if(typeof G_vmlCanvasManager != 'undefined') {  
	    canvas = G_vmlCanvasManager.initElement(canvas);  
	}  
	var context = canvas.getContext("2d");
	
	var clickX = new Array(); 
	var clickY = new Array(); 
	var clickDrag = new Array();
	var _offsetLeft = 0, _offsetTop = 0;
	var paint = false;
	
	var beforMouseX = "";
	var beforMouseY = "";
	
		
	//upload
	var _signatureSelectAnother = "signatureSelectAnother";
	var _localImgSig = "localImgSig";
	var _dropboxUpload = "dropboxUpload";
	var _multipleInput = "multiple";
	var _dropbox = "dropbox";
	
	
	//text signature
	var _textSignature = "textSignature";
	
	
	//date signature
	var _dateSignature = "dateSignature";
	
	var _createSignatureButton = "createSignatureButton";
	
	/**
	 * signature tab show 
	 */
	$(document).on('shown.bs.tab',"#"+_signTab, function (e) {	
		var signatureList = _getSignaturePlugin().getSingnatureList();
		var booleanTemplate = false;
		$("#"+_signatureList).empty();
		for(var key in signatureList){
			var value = signatureList[key];
			if (value) {
				createSignatureHtml(value);
				booleanTemplate = true;
			}
		}
		
		if(booleanTemplate){
			_signatureCreateModal.addClass("disabled");
			$("#"+_getSignatureList).removeClass("disabled");
		}else{
			_signatureCreateModal.removeClass("disabled");
			$("#"+_getSignatureList).addClass("disabled");
		}
	});
	
	/**
	 * signatureModal show
	 */
	_signatureCreateModal.on("click",function(){
		$("#"+_signatureModal).modal("show");
	})
	
	
	/**
	 * sigantureModal berfor show
	 */
	$(document).on("shown.bs.modal","#"+_signatureModal,function(){
		$("#"+_signatureInput).focus();
	})

	/**
	 * signatureModal close
	 */
	$(document).on("click","#"+_signatureModalClose,function(){
		$("#"+_signatureModal).modal("hide");
	})
	
	/**
	 * sigantureModal berfor close 
	 */
	$(document).on('hidden.bs.modal',"#"+_signatureModal, function (e) {
		clearInfo(true);
	});
	
	$(document).on("mouseover","#"+_signatureList+" div",function(){
		$(this).find("."+signatureDeleteClass).css("display","block");
	});
	
	$(document).on("mouseout","#"+_signatureList+" div",function(){
		$(this).find("."+signatureDeleteClass).css("display","none");
	});
	
	$(document).on('click','.'+signatureDeleteClass,function(event){
		event.stopPropagation();
		var itemObj = $(this).parent();
		_getSignaturePlugin().deleteSingnature(_getSignatureIdFromObj(itemObj));
		itemObj.remove();
		_signatureCreateModal.removeClass("disabled");
		$("#"+_getSignatureList).addClass("disabled");
	});
	
	
	$(document).on("click","#"+_signatureList+" div",function(){
		$(".webpdftool").removeClass("hover");
		WebPDF.ViewerInstance.setCurrentToolByName(WebPDF.Tools.TOOL_NAME_SIGNATURE);
		_getSignaturePlugin().setCurSingnature(_getSignatureIdFromObj($(this)));
	});
	
	function _getSignatureIdFromObj(obj) {
		var itemId = obj.attr("id");
		if (itemId) {
			var index = itemId.lastIndexOf('_');
			return itemId.substring(index+1);
		}
		return "";
	}
	//**********************************type  table ************************
	/**
	 * change font style event
	 */
	$(document).on("change","#"+_signatureStyle,function(){
		$("#"+_signatureFontColor).parent().toggle(false);
		fontFamily = $(this).val();
		var inputObj = $("#"+_signatureInput);
		inputObj.css("font-family",fontFamily);
		
		if (fontFamily == "Ventilla" || fontFamily == "Phantom") {
			inputObj.css({"margin-left": "-16px", "text-indent":"45px"});
		} else {
			inputObj.css({"margin-left": "0px", "text-indent":"10px"});
		}
		inputObj.val(inputObj.val());
		
		setTimeout(function(){
			inputObj.focus();
		},10);
	})
	
	/**
	 * key up event
	 */
	$(document).on("keyup","#"+_signatureInput,function(){
		var length = $(this).val().length;
		if(length == 0){
      		clearInfo();
      	 }else{
      		showInfo();
      	 }
	})
	
	/**
	 * clear Input value event
	 */
	$(document).on("click","#"+_signatureClearAll,function(){
		clearInfo();
	});
	
	/**
	 * toggle signature font color
	 */
	$(document).on("click","#"+_signatureColorLi,function(){
		$("#"+_signatureFontColor).parent().toggle();
	});
	
	/**
	 * change signature font color
	 */
	$(document).on("click","#"+_signatureFontColor+" div",function(){
		$(this).parent().parent().toggle();
		color = $(this).attr("colors");
		$("#"+_signatureColorLi+" a div").css("background",color);
		changeInputFont();
		setTimeout(function(){
			document.getElementById(_signatureInput).focus();
			var signatureObject = $("#"+_signatureInput);
			signatureObject.blur(function(){
				signatureObject.focus();
			});
		},10);
	});
	
	
	/**
	 * change font weight style text-decoration
	 */
	$(document).on("click","#"+_fontFamilyType+" div",function(){
		$("#"+_signatureFontColor).parent().hide();
		fontType = $(this).text().replace(/\s+/g, "");
		if(fontType == "B"){
			if(!fontB){
				fontB = true;
				$(this).css("color","#f08200");
			}else{
				fontB = false;
				$(this).css("color","");
			}
		}else if(fontType == "I"){
			if(!fontI){
				fontI = true;
				$(this).css("color","#f08200");
			}else{
				fontI = false;
				$(this).css("color","");
			}
		}else if(fontType == "U"){
			if(!fontU){
				fontU = true;
				$(this).css("color","#f08200");
			}else{
				fontU = false;
				$(this).css("color","");
			}
		}
		changeInputFont();
		setTimeout(function(){
			var tmp = $("#"+_signatureInput).val();
			$("#"+_signatureInput).val("").focus().val(tmp);
		},10);
	});
	
	/**
	 * change input font
	 */
	function changeInputFont(){
		var changeObject = jQuery("#"+_signatureInput);
		var fontWeight = "";
		var textDecoration = "";
		var fontStyle = "";
		if(fontB){
			fontWeight = "bold";
		}
		if(fontU){
			textDecoration = "underline";
		}
		if(fontI){
			fontStyle = "italic";
		}
		changeObject.css("font-weight",fontWeight).css("font-style",fontStyle).css("text-decoration",textDecoration)
		.css("color",color).css("font-family",fontFamily);
	}
	
	//************************draw*******************
	//当鼠标按下时，把paint设为true，表示正在画，鼠标没松开。把鼠标点记录下来。
	$(document).on("mousedown",'#'+_canvasDiv,function(e){
		$("#"+_signatureColorDraw).parent().toggle(false);
		var offset = $(this).offset();
		_offsetLeft= offset.left;
		_offsetTop = offset.top;
	    var mouseX = e.pageX - _offsetLeft;
	    var mouseY = e.pageY - _offsetTop;
	    paint = true; 
	    showInfo();
	    addClick(mouseX, mouseY); 
	    redraw(mouseX,mouseY); 
	})
	
	//当按下鼠标的时候，鼠标移动就把点记录下来并画出来。
	$(document).on("mousemove",'#'+_canvasDiv,function(e){
		if(paint){//是不是按下了鼠标 
		    addClick(e.pageX - _offsetLeft, e.pageY - _offsetTop, true); 
		    redraw(e.pageX - _offsetLeft,e.pageY - _offsetTop,true); 
		} 
	});
	
	
	//鼠标松开事件(Mouse Up Event)
	$(document).on("mouseup",'#'+_canvasDiv,function(e){
		paint =false;
	});
	//鼠标移开事件(Mouse Leave Event)
	$(document).on("mouseleave",'#'+_canvasDiv,function(e){
		paint =false;
	});
	
	function addClick(x, y, dragging) 
	{     
        if (x < 0 || y < 0) return;     
	    clickX.push(x); 
	    clickY.push(y); 
	    clickDrag.push(dragging); 
	} 
	
	function redraws(){ 
		  context.clearRect(0, 0, canvas.width, canvas.height);
		  context.strokeStyle = drawColor; 
		  context.lineJoin = "round"; 
		  context.lineWidth = 5; 
		  context.beginPath(); 
		  for(var i=0; i < clickX.length; i++) 
		  { 
		    context.beginPath(); 
		    if(clickDrag[i] && i){//当是拖动而且i!=0时，从上一个点开始画线。 
		      context.moveTo(clickX[i-1], clickY[i-1]); 
		     }else{ 
		       context.moveTo(clickX[i]-1, clickY[i]); 
		     } 
		     context.lineTo(clickX[i], clickY[i]); 
		     context.closePath(); 
		     context.stroke(); 
		  } 
	}
	
	function redraw(mouseX,mouseY,drag){ 
	  context.strokeStyle = drawColor; 
	  context.lineJoin = "round"; 
	  context.lineWidth = 5; 
	  context.beginPath(); 
	  if(drag){
		  context.moveTo(beforMouseX,beforMouseY); 
	  }else{
		  context.moveTo(mouseX-1,mouseY); 
	  }
	  context.lineTo(mouseX, mouseY); 
	  context.closePath(); 
	  context.stroke();
	  
	  beforMouseX = mouseX;
	  beforMouseY = mouseY;
	}
	
	/**
	 * cleare drawing event
	 */
	$(document).on("click","#"+_clearAllDraw,function(){
		clearInfo();
	});
	
	$(document).on("click","#"+_signatureColorLiDraw,function(){
		$("#"+_signatureColorDraw).parent().toggle();
	});
	
	$("#"+_signatureColorDraw+" div").click(function(){
		$(this).parent().parent().toggle();
		drawColor = $(this).attr("colors");
		$("#"+_signatureColorLiDraw+" a div").css("background",drawColor);
		redraws();
	});
	
	/**
	 * clear drawing board
	 */
	function cleanSignatureDalogAllData() {
		clickX.length = clickY.length = clickDrag.length = 0;
		context.clearRect(0, 0, canvas.width, canvas.height);
	}
	
	/**
	 * point to img
	 */
	function pointToImg() {
		 var canvasDivs = document.getElementById('cacleCanvas');
		 if (!canvasDivs || canvasDivs.length <= 0) {
	       	$("#Viewer").append('<div id="cacleCanvas" style="display:none"></div>"');
	       	canvasDivs = document.getElementById('cacleCanvas');
		 }
         var orig_canvas = document.getElementById('canvas');
		 var canvass = document.createElement('canvas');
	        
	     var maxWidth = minWidth = clickX[0],maxHeight = minHeight=clickY[0];
	     for (var i=1; i<clickX.length; i++) {
	        	maxWidth =  Math.max(maxWidth, clickX[i]);
	        	maxHeight =  Math.max(maxHeight, clickY[i]);
	        	minWidth =  Math.min(minWidth, clickX[i]);
	        	minHeight =  Math.min(minHeight, clickY[i]);              
	        }
       
       maxHeight = Math.min(orig_canvas.height,  maxHeight);
       maxWidth = Math.min(orig_canvas.width, maxWidth);
     
       canvass.width = maxWidth - minWidth;
       canvass.height = maxHeight - minHeight;        
    
       if(typeof G_vmlCanvasManager != 'undefined') {  
   	    canvass = G_vmlCanvasManager.initElement(canvass);  
       }
       var context = canvass.getContext('2d');                
       
       context.drawImage(orig_canvas,minWidth, minHeight, maxWidth,maxHeight, 0, 0, canvass.width, canvass.height);
       return {"dataurl":canvass.toDataURL("image/png"),"width":canvass.width,"height":canvass.height};
   }
	
	//************************upload*******************
	$("#multipleUploadForm,#dropbox").dmUploader({  
		url: "./previewImage",
        formElemId: "multipleUploadForm",
        dataType: 'json',
        allowedTypes: 'image/*',
        onInit: function(){
        },
        onBeforeUpload: function(id){
        },
        onNewFile: function(id, file){},
        onSubmit: function(){
        },
        onComplete: function(){
        },
        onUploadProgress: function(id, percent){
        },
        onUploadSuccess: function(id, data){
        	var error = data.error;
        	var base64Data = data.base64Data;
        	if(typeof error === "undefined"){
        		var jsonData = JSON.parse(data);
        		error = jsonData.error;
        		base64Data = jsonData.base64Data;
        	}
        	if(error == "0"){
        		if(WebPDF.Environment.ie){
    				jQuery("#multiple").css("margin-left","250px").css("margin-top","200px");
    			}
        		jQuery("#localImgSig").attr("src","data:image/gif;base64,"+base64Data);
        		showInfo();
        	}else{
        		alert("Get Image Base64 Data faile");
        	}
        },
        onUploadError: function(id, message){
        },
        onFileTypeError: function(file){
            alert("The signature is not Image format.");
        },
        onFileSizeError: function(file){
            
        },
        onFileExtError: function(file){
        },
        onFallbackMode: function(message){
        }
    });
	
	$("#"+_signatureSelectAnother+", #"+_dropbox).click(function(){
		$("#"+_multiple).click();
	});
	//*********************end***************************
	
	/**
	 * type draw upload(signature) tab change event
	 */
	$(document).on("click",".signatureType",function(){
		var tmpViewFileType = $(this).attr("viewFileType");
		if (tmpViewFileType) {
			viewFileType = tmpViewFileType;
		}
		if(viewFileType == "upload"){
			//ie 下  改变 input位置
			if(WebPDF.Environment.ie){
				jQuery("#"+__multipleInput).css("width","230px").css("margin-top","153px").css("height","22px").css("margin-left","0px");
			}
			if($("#"+_signatureSelectAnother).css("display") != 'none'){
				showInfo();
			}else{
				clearInfo();
			}
			$("#"+_signatureInput).blur();
		}else if(viewFileType == "draw"){
			$("#"+_signatureFontColor).parent().toggle(false);
			if($("#"+_clearAllDraw).css("opacity") < 1){
				clearInfo();
			}else{
				showInfo();
			}
			$("#"+_signatureInput).blur();
		}else if(viewFileType == "type"){
			$("#"+_signatureColorDraw).parent().toggle(false);
			if($("#"+_signatureClearAll).css("opacity") < 1){
				clearInfo();
			}else{
				showInfo();
			}
		}
	});
	
	
	
	/**
	 * show signature list event
	 */
	$(document).on("click","#"+_getSignatureList,function(){
		$("#"+_signatureList).toggle();
	})
	
	/**
	 * modal create Signature event 
	 */
	$(document).on("click","#"+_createSignatureButton,function(){
		if ($(this).css("opacity") < 0.8) {
			return;
		}
		$("#"+_signatureList).hide();
		var singnaturePlugin = _getSignaturePlugin();
		var singnatureObj = null;
		if (viewFileType == "type") {
			var textValue = trim($("#"+_signatureInput).val());
			var imgObj = textToImg(textValue, fontFamily, fontSize, color, fontB, fontI, fontU);
			var singnatureObj = singnaturePlugin.addSingnature(WebPDF.PDFData.SignatureType.Img, imgObj.dataurl, imgObj.width,imgObj.height);
		} else if (viewFileType == "draw") {
			var imgObj = pointToImg();
			var singnatureObj = singnaturePlugin.addSingnature(WebPDF.PDFData.SignatureType.Img, imgObj.dataurl, imgObj.width,imgObj.height);
		} else if(viewFileType == "upload"){
			var imgObj = jQuery("#"+_localImgSig);
			var singnatureObj = singnaturePlugin.addSingnature(WebPDF.PDFData.SignatureType.Img, imgObj.attr("src"), imgObj.width(),imgObj.height());
		}
		if (singnatureObj) {
			WebPDF.ViewerInstance.setCurrentToolByName(WebPDF.Tools.TOOL_NAME_SIGNATURE);
			singnaturePlugin.setCurSingnature(singnatureObj.getId());
			createSignatureHtml(singnatureObj);
		}
		$('#'+_signatureModal).modal('hide');
		_signatureCreateModal.removeClass("createsign24").addClass("disabled");
		$("#"+_getSignatureList).removeClass("disabled");
	});
	
	/**
	 * create signature List Html
	 */
	function createSignatureHtml(_signatureObject){
		var fileType = _signatureObject.getType();
		var str = "";
		if(fileType == "text"){
			str = _signatureObject.getSignatureText();
		}else if(fileType == "img"){
			str = '<img class="fwr-signature-item-img" src="'+_signatureObject.getFilePath()+'" tabindex=3 onerror="javascript:this.src=\'' + "../images/signature/searching.gif" + '\'"></img>';
		}
		var html = '<div id="signatureSelect_' + _signatureObject.getId() + '"  tabindex=2>'+
							str+
						'<span class="fwr-signature-item-delete" tabindex=3 style="display:none;"></span>'+
					'</div>';
		
		$("#"+_signatureList).append(html);
	}
	
	/**
	 * text to Img 
	 */
	function textToImg(content, fontName, fontSize, fontColor, bBold, bItalics, bUnderline) {
        var fontWeight = "";
        if (bBold) {
        	fontWeight = "bold ";
        }
        if (bItalics) {
        	fontWeight += "italic ";
        }
    	
        var canvasDivs = document.getElementById('cacleCanvas');
        if (!canvasDivs || canvasDivs.length <= 0) {
        	$("#"+_signatureModal).parent().append('<div id="cacleCanvas" style="display:none"></div>"');
        	canvasDivs = document.getElementById('cacleCanvas');
        }
        var canvass = document.createElement('canvas');
        
        var id = "SpellCeckSpan" + (new Date()).valueOf().toString();
        var editObj = $("#"+_signatureInput);
        var spanCode = '<span id= "' + id + '" style= "line-height:100%;position:absolute;visibility:hidden;border:0;padding:0;font-size:' + fontSize + 'px;font-family:' + fontName + ';"></span>';
        editObj.after(spanCode);
        var tmpSpanObj = $("#" + id);
        tmpSpanObj.html("text");
        var lineHeight = tmpSpanObj.height();
        tmpSpanObj.html(content.replace(/ /g, '&nbsp;'));
        var width = tmpSpanObj.width();
        var height = tmpSpanObj.height();
        if (lineHeight+10 < height) {
        	var lineCount = parseInt(height / lineHeight) + 1;
        	width = 0;
        	var lineTxtConunt = parseInt(content.length / lineCount);
        	for (var i=0; i<lineCount; i++) {
        		var str = content.substring(lineTxtConunt*i, lineTxtConunt);
        		if (i == lineCount-1)
        			str = content.substring(lineTxtConunt*i);
        		tmpSpanObj.html(str.replace(/ /g, '&nbsp;'));
                width += tmpSpanObj.width();
        	}
        }
        height = Math.max(height, parseInt(fontSize*1.25));     
        var leftRightWidth = 5;
        tmpSpanObj.remove();
        if (content.length > 0 && (fontName == "Ventilla" || fontName == "Phantom")) {
        	leftRightWidth = parseInt(width / content.length + 0.5);
        }
        canvass.width = width + leftRightWidth*2;
        canvass.height = height;
        
        canvasDivs.appendChild(canvass);  
        if(typeof G_vmlCanvasManager != 'undefined') {  
    	    canvass = G_vmlCanvasManager.initElement(canvass);  
        }
        var contexts = canvass.getContext('2d');
        
        contexts.clearRect(0, 0, canvass.width, canvass.height);
        contexts.fillStyle = fontColor;
        contexts.font = fontWeight + fontSize + "px/" + fontSize + "px " + fontName;
        contexts.textBaseline = 'top';
        canvass.style.display = 'none';
        contexts.fillText(content, leftRightWidth, canvass.height/2 - fontSize/2, canvass.width-leftRightWidth*2);
        if(bUnderline){
        	var underLineHeight = height-15;
        	if (fontName == "Phantom") {
        		underLineHeight += 10;
        	}
        	contexts.beginPath();
        	contexts.strokeStyle = fontColor;
        	contexts.moveTo(leftRightWidth,underLineHeight);
        	contexts.lineTo(width + leftRightWidth,underLineHeight);
        	contexts.closePath();
        	contexts.stroke();
        	contexts.fill();
        }
        return {"dataurl":canvass.toDataURL("image/png"),"width":canvass.width,"height":canvass.height};
    }
	
	function trim(str) {
        //删除左右两端的空格
        return str.replace(/(^\s*)|(\s*$)/g, '');
    }
	
	function _signatureToolBackGround(){
		$(".fwr-select-date-wrapper").css("background-image","");
		$(".fwr-select-signature-wrapper").css("background-image","");
		$(".fwr-select-text-wrapper").css("background-image","");
	}
	
	function _getSignaturePlugin() {
		var signaturePlugin = WebPDF.ViewerInstance.getPluginByName(WebPDF.SignaturePluginName);
		signaturePlugin.setSignToPageCompleteEventHandler(_signatureToolBackGround);
		return signaturePlugin;
	}
	
	function clearInfo(closeSignatureModal){
		if(closeSignatureModal){
			color = defaultColor
			drawColor = defaultColor
			fontB = false;
			fontI = false;
			fontU = false;
			
			fontFamily = "Anacondas";
			viewFileType = "type";
			
			//默认显示type table
			$("#"+_signatureContent+" a:first").tab('show');
			
			//type
			changeInputFont();
			
			$($("#"+_signatureStyle).find("option")[0]).attr("selected","selected");
			$("#"+_signatureColorLi+" div").css("background",color);
			$("#"+_fontFamilyType+" div").each(function(){
				$(this).css("color","");
			});
			
			//draw 
			$("#"+_signatureColorLiDraw+" div").css("background",drawColor);
			cleanSignatureDalogAllData();
			$("#"+_clearAllDraw).css("opacity","0.35").css("cursor","auto");
			$("#"+_drawBackground).show();
			
			//upload
			jQuery("#"+_signatureSelectAnother).hide();
			jQuery("#"+_localImgSig).hide().attr("src","");
			jQuery("#"+_dropboxUpload).show();
		}
		
		if(viewFileType == "upload"){
			jQuery("#"+_signatureSelectAnother).hide();
			jQuery("#"+_localImgSig).hide().attr("src","");
			jQuery("#"+_dropboxUpload).show();
		}else if(viewFileType == "draw"){
			cleanSignatureDalogAllData();
			$("#"+_clearAllDraw).css("opacity","0.35").css("cursor","auto");
			$("#"+_drawBackground).show();
		}else if(viewFileType == "type"){
			$("#"+_signatureInput).val("");
			$("#"+_signatureInput).focus();
			$("#"+_signatureInputBackgroud).show();
			$("#"+_signatureClearAll).css("opacity","0.35").css("cursor","auto");
		}
		$("#"+_createSignatureButton).css("opacity","0.3").css("cursor","auto");
	}
	
	function showInfo(){
		if(viewFileType == "upload"){
			$("#"+_signatureSelectAnother).show();
			$("#"+_localImgSig).show();
			$("#"+_dropboxUpload).hide();
		}else if(viewFileType == "draw"){
			$("#"+_clearAllDraw).css("opacity","1").css("cursor","pointer");
			$("#"+_drawBackground).hide();
		}else if(viewFileType == "type"){
			var signatureClearAll = $("#"+_signatureClearAll);
			signatureClearAll.css("opacity","1").css("cursor","pointer");
			$("#"+_signatureInputBackgroud).hide();
		}
		$("#"+_createSignatureButton).css("opacity","1").css("cursor","pointer");
	}
	
	//**************************create text signature start*********************************
	$("#"+_textSignature).on('click', function(){
		$(".webpdftool").removeClass("hover");
		WebPDF.ViewerInstance.setCurrentToolByName(WebPDF.Tools.TOOL_NAME_SIGNATURE);
		_getSignaturePlugin().setCurSingnature(WebPDF.PDFData.BaseSignature.Text);
		$(this).addClass("hover");
	});
	
	//**************************create text signature end******************************************
	
	

	//**************************create date signature start****************************************
	$("#"+_dateSignature).on('click', function(){
		$(".webpdftool").removeClass("hover");
		WebPDF.ViewerInstance.setCurrentToolByName(WebPDF.Tools.TOOL_NAME_SIGNATURE);
		_getSignaturePlugin().setCurSingnature(WebPDF.PDFData.BaseSignature.Date);
		$(this).addClass("hover");
	});
	
	
	//**************************create date signature end******************************************
});